package map;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demon03HashMap {
    public static void main(String[] args) {
        System.out.println("遍历map......");
        Map map=new HashMap();
        map.put("s01","zs");
        map.put("s02","ls");
        map.put("s03","ww");
        Set set1=map.keySet();//将双值集合，降成单值集合
        for(Object o:set1)
        {
            System.out.println("key:  "+o);
            Object v=map.get(o);//map可以根据key，获取value;map.get(key)得到value
            System.out.println("value: "+v);
        }
        System.out.println("通过entry遍历。。。");
        Set entrySet = map.entrySet();
        for(Object e:entrySet)
        {
            Map.Entry e1 = (Map.Entry) e;//要想遍历输出Map需要强转
            Object k = e1.getKey();
            Object v = e1.getValue();
            System.out.println("K-"+k);
            System.out.println("v-"+v);
        }
    }
}
